package J1_22;

import java.util.Scanner;
//22题任务三
public class J122task3 {
    public static void main(String[] args) {
        int n,s=0;
        Scanner scanner =new Scanner(System.in);
        System.out.printf("输入一个整数:");
        n=scanner.nextInt();

    while (true){
        if (!(n>=2&&n<=1000)){
            System.out.print("输入有误,再一次输入:");
            n=scanner.nextInt();
        }
        else {
            break;
        }
    }
       for (int i=2;i<=n;i++){
           if (isPrime(i)==true){
               s=s+i;
           }
       }
        System.out.println(s);
    }
    private  static  boolean isPrime(int n){
        double s=Math.sqrt(n);
        boolean f=true;
       for (int i=2;i<s;i++){
           if(n%i==0){
               f=false;
               break;
           }
       }
         return  f;
    }
}
